import React from 'react';
import { connect } from 'react-redux'
import {withRouter } from 'react-router-dom'
import { companyMenu } from '../../redux/company/company'
import CompanyModel from './CompanyModel'
import { Divider } from 'antd';
@withRouter
@connect(
    state => state,
    {companyMenu}
)
export default class Company extends React.Component {
    constructor(){
        super();
        this.state = {
            visible:false
        }
    }
    componentWillReceiveProps(nextProps){
          if(nextProps.company.companyState){
            this.props.companyMenu();
            this.showModel();
          }
    }
    onCompany(){
      this.setState({
          visible:true
      })
    }
    showModel(){
        this.setState({
            visible:!this.state.visible
        })
    }

    componentDidMount(){
        this.props.companyMenu();
    }
    render() {
        console.log(this.props)
        let companys = this.props.company.companys
        return (
               
               !companys ? '' :
               <div  style={{width:'80%',margin:'0 auto',overflow:'hidden',paddingBottom:50}}>
                    <div style={{fontSize:'20px',textAlign:'center',paddingTop:20,paddingBottom:10}}>企业信息详情</div>
                    <div>基本信息</div>
                    <Divider/>
                    <div style={{float:"left",width:'50%'}}>
                    <div style={{paddingBottom:10}}>企业名称：{companys.companyName}</div>
                    <div style={{paddingBottom:10}}>企业地址：{companys.address}</div>
                    <div style={{paddingBottom:10}}>联系人：{companys.contactMan}</div>
                    <div style={{paddingBottom:10}}>手机：{companys.mobilePhone}</div>
                    <div style={{paddingBottom:10}}>电话{companys.phone}</div>
                    <div style={{color:'#1890ff',paddingBottom:10}} onClick={this.onCompany.bind(this)}>点击添加企业信息</div>
                    </div>
                    <div style={{float:"left",width:'48%'}}>
                    <div style={{paddingBottom:10}}>专属客户经理：{companys.customerManager}</div>
                    <div style={{paddingBottom:10}}>联系电话：{companys.customerManagerPhone}</div>
                    <div style={{paddingBottom:10}}>备注：{companys.note}</div>
                    </div>
                    
                    
                    <CompanyModel visible={this.state.visible} showModel={this.showModel.bind(this)}/>
                </div>
           
        );
    }
}